Component({
    //暴露类名，给使用组件的地方覆盖组件样式
    externalClasses: ["tag-class"],


    properties: {
        goodsList: {
            type: Object,
            value: []
        },
        filterCategory: {
            type: Object,
            value: []
        },
        isShowFilter: {
            type: Boolean,
            value: false
        }
    },
    observers: {
        // 属性监听，监听分类属性，如果发生改变就将其处理成想要的数据格式
        'filterCategory': function (newVal, oldVal) {
            // console.log(newVal);
            let currentCheckCatId = 0;
            let newOption = newVal.map(item => {
                if (item.checked) currentCheckCatId = item.id;
                return {
                    text: item.name,
                    value: item.id
                }
            })
            this.setData({
                option3: newOption,
                value3: currentCheckCatId
            })
        }
    },

    data: {
        option1: [{
                text: '综合',
                value: 0
            },

        ],
        option2: [{
                text: '价格从高到低',
                value: 'desc'
            },
            {
                text: '价格从低到高',
                value: 'asc'
            },

        ],
        option3: [{
                text: '全部',
                value: 'a'
            },
            {
                text: '居家',
                value: 'b'
            }
        ],
        value1: 0,
        value2: 'asc',
        value3: 'a',
    },
    methods: {
        goToProduct(e) {
            // console.log(e.currentTarget.dataset.goodsid);
            wx.navigateTo({
                url: '/pages/product/product?goodsid=' + e.currentTarget.dataset.goodsid,
            })
        },
        orderPrice(e) {
            // console.log(e.detail);
            this.triggerEvent('orderPrice', e.detail)
        },
        orderCategroy(e) {
            this.triggerEvent('orderCategroy', e.detail)
        }
    }

})